#!/bin/sh
#desc: Monta las unidades de red

# Copyright(c) 2011 OpenDomo Services SL. Licensed under GPL v3 or later

CONF=/etc/opendomo/nfsdrives
mkdir -p $CONF
chown admin:admin $CONF
chmod 0775 $CONF
echo -n "Mounting network drives..."
if test -x /usr/sbin/rpc.mountd && test -x /sbin/mount.nfs 
then
	/usr/sbin/rpc.mountd
else
	echo "(Tools not installed)"
	exit 2
fi
if test -d "$CONF"; then
	cd $CONF
else
	echo "(config missing)"
	exit 2
fi
for i in *; do
	if test "$i" != "*"; then
		LABEL=`basename $i`
		DRVPATH=`cat $i`
		mkdir -p /media/$LABEL
		if /sbin/mount.nfs $DRVPATH /media/$LABEL 2>/dev/null
		then
			echo -n "($LABEL)"
			/usr/bin/logger -p notice "Network drive $LABEL mounted"
		else
			rm -fr /media/$LABEL
		fi
	fi
done
exit 0
